﻿using System.IO;

namespace NazTek.Extension.Clr4
{
    /// <summary>
    /// Informaion about a compressed file
    /// </summary>
    public sealed class CompressedFileInfo
    {
        /// <summary>
        /// Underlying file informaion
        /// </summary>
        public FileInfo FileInfo { get; private set; }
        /// <summary>
        /// Compression ratio
        /// </summary>
        public float CompressionRatio { get; private set; }
        /// <summary>
        /// constructs a <see cref="FileInfo"/> instance for the compressed file and calculates the compression ratio
        /// </summary>
        /// <param name="compressedFileName">The full file path used o instantiate the undelying <see cref="FileInfo"/></param>
        /// <param name="uncompressedFileLength">Uncompressed file length, used to calculate compression ratio</param>
        /// <remarks>Compression ratio is calculated as : (inFile.Length - outFile.Length) * 100 / inFile.Length</remarks>
        internal CompressedFileInfo(string compressedFileName, float uncompressedFileLength)
        {
            FileInfo = new FileInfo(compressedFileName);
            CompressionRatio = ((float)(uncompressedFileLength - FileInfo.Length)) * 100 / uncompressedFileLength;
        }
    }
}
